package cate.game.play.buff.h;

import cate.common.table.d.GDSkill;
import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.AppendMove;
import cate.game.play.proce.move.AppendMoveHandler;
import cate.game.play.proce.move.MoveCtx;
import cate.game.play.proce.turn.TurnCtx;
import cate.game.play.skill.Skill;

/**
 * 每次攻击后追加一次:对敌方随机3个单位造成106%+目标损失血量百分比*60%的物理伤害，30%附加1回合[沉默]，最多追加3次
 */
public class 暴雨梨花BH extends BuffHandler implements AppendMoveHandler {


	private int 追加技能;

	private int 次数;

	//追加技能=？？&次数=3
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		追加技能 = args.getInt("追加技能", 0);
		次数 = args.getInt("次数", 0);
	}

	private int roundTime;

	@Override
	public void onOwnerMoveDone(MoveCtx move, TimeActionCtx action) {
		if (!move.skill.cfg.isEffectType(GDSkill.EffectType.伤害)) {
			return;
		}
		if (move.getSkill().cfg.id == 追加技能) {
			return;
		}
		if (roundTime >= 次数) {
			return;
		}
		Skill appendSkill = move.getCfg().skill.buildById(buff.owner, 追加技能);
		if (appendSkill == null) {
			return;
		}
		move.getTurn().addAppend(new AppendMove(buff.owner, appendSkill,this));
	}

	@Override
	public void onRoundBegin(ActionCtx action) {
		roundTime = 0;
	}

	@Override
	public boolean inValid(TurnCtx turn, AppendMove appendMove) {
		return roundTime >= 次数;
	}

	@Override
	public void beforeAppendMove(TurnCtx turn, AppendMove appendMove) {

	}

	@Override
	public void afterAppendMove(TurnCtx turn, AppendMove appendMove) {
		roundTime++;
	}

	@Override
	public void onAppendMoveFail(TurnCtx turn, AppendMove appendMove) {
	}
}
